//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.atguigu.gulimall.coupon.controller;

import com.atguigu.common.to.SkuReductionTo;
import com.atguigu.common.utils.PageUtils;
import com.atguigu.common.utils.R;
import com.atguigu.gulimall.coupon.entity.SkuFullReductionEntity;
import com.atguigu.gulimall.coupon.service.SkuFullReductionService;
import java.util.Arrays;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping({"coupon/skufullreduction"})
public class SkuFullReductionController {
    @Autowired
    private SkuFullReductionService skuFullReductionService;

    public SkuFullReductionController() {
    }

    @PostMapping({"/saveinfo"})
    public R saveInfo(@RequestBody SkuReductionTo reductionTo) {
        this.skuFullReductionService.saveSkuReduction(reductionTo);
        return R.ok();
    }

    @RequestMapping({"/list"})
    public R list(@RequestParam Map<String, Object> params) {
        PageUtils page = this.skuFullReductionService.queryPage(params);
        return R.ok().put("page", page);
    }

    @RequestMapping({"/info/{id}"})
    public R info(@PathVariable("id") Long id) {
        SkuFullReductionEntity skuFullReduction = (SkuFullReductionEntity)this.skuFullReductionService.getById(id);
        return R.ok().put("skuFullReduction", skuFullReduction);
    }

    @RequestMapping({"/save"})
    public R save(@RequestBody SkuFullReductionEntity skuFullReduction) {
        this.skuFullReductionService.save(skuFullReduction);
        return R.ok();
    }

    @RequestMapping({"/update"})
    public R update(@RequestBody SkuFullReductionEntity skuFullReduction) {
        this.skuFullReductionService.updateById(skuFullReduction);
        return R.ok();
    }

    @RequestMapping({"/delete"})
    public R delete(@RequestBody Long[] ids) {
        this.skuFullReductionService.removeByIds(Arrays.asList(ids));
        return R.ok();
    }
}
